import request from '@/request';

export const getGoodList = function <T, U>(params: T): Promise<U> {
    return request({
        method: 'get',
        url: 'good/list',
        params,
    });
};

export const fetchBanners = function <T, U>(params: T): Promise<U> {
    return request({
        method: 'get',
        url: 'banner/list',
        params,
    });
};
export const getGoodDetail = function <U>(id: string): Promise<U> {
    return request({
        method: 'get',
        url: 'good/detail/' + id,
    });
};

export const fetchEditGood = function <T, U>(id: string, data: T): Promise<U> {
    console.log(id, data);

    return request({
        method: 'post',
        url: 'good/update/' + id,
        data,
    });
};

export const fetchCreateGood = function <T, U>(data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/good/create',
        data,
    });
};
